Measles cases across the world

TidyTuesday 2025-06-24

r
geofacet
data.table
data-viz
Author

gnoblet

Published

June 24, 2025

Overview

This week’s TidyTuesday focused on measles cases across the world. I explored a very minimal viz around red rashes using a global point geofacet.

Dataset

Code
# Libraries
box::use(
    gg = ggplot2,
    ggf = geofacet,
    ggt = ggtext,
    tidytuesdayR[tt_load],
    ggp = patchwork,
    data.table[...],
    sht = showtext,
    syf = sysfonts
)

# Get data
dat <- tt_load("2025-06-24")
dat_month <- dat$cases_month
setDT(dat_month)  

Analysis

Data Preparation

Code
# Aggregate by year 
dat_month <- dat_month[, .(measles_clinical = sum(measles_clinical)), by = .(year, iso3)]

Visualization

Code
# Get grid
data("world_countries_grid1", package = "geofacet")

# Fonts
syf$font_add_google("Fascinate Inline", "Fascinate Inline")
sht$showtext_auto()
sht$showtext_opts(dpi = 600)
title_font <- "Fascinate Inline"

# Measles colors
colors <-  c(
    '#F4A6A6',  # light coral, reflecting the lighter areas of the rash
    '#E25822', # a strong red-orange, often used for rashes or spots
    '#B22222'  # a deep firebrick, suitable for the darker spots or advanced rash stages
 )

# Tag
tag <- "<span style='color:#B22222;font-size:22pt;'>Clinically-compatible measles cases</span><br><br>
                <span style='color:#E25822;font-size:14pt;'>A suspected case with fever, maculopapular rash, and at least one of cough, coryza, or conjunctivitis, without a clinical specimen or epidemiological link to a confirmed case.</span>"
   
# Plot
g <- gg$ggplot(dat_month) +
    gg$aes(x = year, y = measles_clinical, color = measles_clinical, size = measles_clinical) + 
    gg$geom_point() +
    gg$scale_size_continuous(range = c(0.3, 4.5)) +
    gg$scale_color_gradientn(colors = colors) +
    ggf$facet_geo(~iso3, grid = 'world_countries_grid1') +
    gg$theme_void() +
    gg$labs(tag = tag) +
    gg$theme(
        plot.background = gg$element_rect(fill = 'white'),
        strip.background = gg$element_blank(),
        strip.text.x = gg$element_blank(),
        legend.position = 'none',
        plot.tag.position = c(0.05, 0.15),
        plot.tag = ggt$element_textbox_simple(
            family = title_font,
            width = gg$unit(4.5, "inch"),
            lineheight = 1.2,
            hjust = 0
        )
    ) 

# Create the main visualization
gg$ggsave('week_25.png', g, height = 10, width = 16, dpi = 600)

Technical Notes